package com.mdd.admin.validate.system;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.mdd.admin.validate.BaseParam;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.common.validator.annotation.IntegerContains;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import lombok.Data;

import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 优惠券参数
 * @author panweiliang
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class CouponParam extends BaseParam {

    @IDMust(message = "id参数必传且需大于0", groups = {update.class, delete.class})
    private Integer id;

    @NotNull(message = "优惠券名称不能为空", groups = {create.class, update.class})
    @Length(max = 255, message = "优惠券名称不能超出255个字符", groups = {create.class, update.class})
    private String title;

    private String icon;

    @NotNull(message = "使用范围不能为空", groups = {create.class, update.class})
    @IntegerContains(values = {1, 2, 3}, message = "使用范围取值不在符合范围", groups = {create.class, update.class})
    private Integer used;

    @NotNull(message = "使用门槛不能为空", groups = {create.class, update.class})
    @IntegerContains(values = {1, 2, 3}, message = "使用门槛取值不在符合范围", groups = {create.class, update.class})
    private Integer type;

    @NotNull(message = "领取方式不能为空", groups = {create.class, update.class})
    @IntegerContains(values = {1, 2}, message = "领取方式取值不在符合范围", groups = {create.class, update.class})
    private Integer receivingMethod;

//    @NotNull(message = "fullAmount参数缺失", groups = {create.class, update.class})
//    @DecimalMin(value = "0", message = "fullAmount参数值不能少于0", groups = {create.class, update.class})
    private BigDecimal fullAmount;

    @NotNull(message = "优惠券面额不能为空", groups = {create.class, update.class})
    @DecimalMin(value = "0", message = "优惠券面额不能少于0", groups = {create.class, update.class})
    private BigDecimal amount;

    private Short isQuota = 0;

//    @NotNull(message = "发券数量不能为空", groups = {create.class, update.class})
//    @DecimalMin(value = "0", message = "发券数量不能少于0", groups = {create.class, update.class})
    @DecimalMax(value = "1000000", message = "发券数量不能超过1000000", groups = {create.class, update.class})
    private Integer quota;

    @NotNull(message = "领取方式取值不能为空", groups = {create.class, update.class})
    @IntegerContains(values = {1, 2, 3}, message = "领取方式取值不在符合范围", groups = {create.class, update.class})
    private Integer takeType;

    @DecimalMin(value = "0", message = "takeQuota参数值不能少于0", groups = {create.class, update.class})
    private Integer takeQuota;

//    private Integer takeCount;

    @NotNull(message = "使用时间类型不能为空", groups = {create.class, update.class})
    @IntegerContains(values = {1, 2, 3}, message = "使用时间类型取值不在符合范围", groups = {create.class, update.class})
    private Integer validType;

//    @NotNull(message = "validStartTime参数缺失", groups = {create.class, update.class})
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date validStartTime;

//    @NotNull(message = "validEndTime参数缺失", groups = {create.class, update.class})
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date validEndTime;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date startTime;

    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date endTime;

//    @NotNull(message = "validDays参数缺失", groups = {create.class, update.class})
    @DecimalMin(value = "0", message = "使用时间不能少于0", groups = {create.class, update.class})
    private Integer validDays;

    private Integer status;

//    @NotNull(message = "courseIds", groups = {create.class, update.class})
//    @NotEmpty(message = "courseIds is not empty", groups = {create.class, update.class})
    private List<Integer> courseIds;

}
